/*	kd:
	This assigns each player their aspect ratio. You must call GetAspectRatio in
	UI scope, or else you'll face a desync in multiplayer. Net events help do
	the rest. */

class Gc_PlayerScreen : EventHandler {
	float m_aspect [MAXPLAYERS];
	int   m_width  [MAXPLAYERS];
	int   m_height [MAXPLAYERS];
	
	const ARG_WIDTH    = 0;
	const ARG_HEIGHT   = 1;
	const ARG_PLAYER   = 2;
	
	override void UiTick () {
		SendNetworkEvent("Gc_ScreenDims",
			Screen.GetWidth(), Screen.GetHeight(), consoleplayer);
	}
	
	override void NetworkProcess (ConsoleEvent event) {
		int          p_num    = event.player;
		PlayerInfo   player   = players [p_num];
		
		if(p_num < 0 || !player || !player.mo) {
			return;
		}
		
		if(event.name ~== "Gc_ScreenDims") {
			if(p_num != event.args [ARG_PLAYER]) {
				
			}
			
			float width    = event.args [ARG_WIDTH];
			float height   = event.args [ARG_HEIGHT];
			m_aspect   [p_num] = width / max(1, height);
			m_width    [p_num] = width;
			m_height   [p_num] = height;
		}
	}
}
